#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

int main(void)
{
    const char* const str[] = 
    {
        "The term buccaneer comes from the workd boucan.\n",
        "A boucan is a wooden frame used for cooking meat.\n",
        "Buccaneer is the West Indies name for a pirate.\n"
    };
    struct iovec v[] = 
    {
        {(void*)str[0], strlen(str[0])},
        {(void*)str[1], strlen(str[1])},
        {(void*)str[2], strlen(str[2])},
    };


    int fd = open("buccaneer.txt", O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
    if (fd == -1)
    {
        printf("error = %d\n", errno);
        perror("open");
    }
    ssize_t res = writev(fd, v, 3);
    printf("write result %ld\n", res);
    close(fd);
}